void getNumber(vector<vector<char>>& grid, int i, int j)
{
    if(i >= grid.size() || i < 0)
        return ;
    if(j >= grid[0].size() || j < 0)
        return ;

    if(grid[i][j] == '1')
    {
        grid[i][j] = '0';
        getNumber(grid, i + 1, j);
        getNumber(grid, i - 1, j);
        getNumber(grid, i, j + 1);
        getNumber(grid, i, j - 1);
    
    }
} 


class Solution {
public:
    int numIslands(vector<vector<char>>& grid) 
    {
        int count = 0;

        for(int i = 0; i < grid.size(); i++)
        {
            for(int j = 0; j < grid[0].size(); j++)
            {
                if(grid[i][j] == '1')
                {
                    count++;
                    getNumber(grid, i, j);
                }
            }
        }

        return count;
    }
};